class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2025-03-20",
      revision: "04fa5ba95dca9caf5528c27a0840391c671908f2"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "92eff34fe5fb23dc0ade3f2abe5cf8cf5734a123c089f03b5771512f40fe56df"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "551b97949572f5a56be9fd77dcd17c21a55e36590438b39022b5af20d1d53019"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "42d4290dca230a8ad6aa311757f2ffe59bafb60526bfa8f05061707a9dddac0d"
    sha256 cellar: :any_skip_relocation, sonoma:        "b345436c5f0e9d99ce19e86bebc20ad57fa24ef6fca54c926d732b06cce94fa8"
    sha256 cellar: :any_skip_relocation, ventura:       "db422acfd0b9531b75a91f3e7f08c8adebbe34cf9016c00e9b7101efa86482eb"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "dbed6ea38dfe66bafd07f925751c8373545465082eeaeac62734ccb0315be89f"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
